<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>s6: the s6-svlisten1 program</title>
    <meta name="Description" content="s6: the s6-svlisten1 program" />
    <meta name="Keywords" content="s6 command s6-svlisten1 notification service waiting" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">s6</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The s6-svlisten1 program </h1>

<p>
 s6-svlisten1 runs a program while listening on notifications from a
supervised service, and blocks until said service goes up, or down.
</p>

<p>
 s6-svlisten1 only waits for notifications; it never polls.
</p>

<h2> Interface </h2>

<pre>
     s6-svlisten1 [ -U | -u | -D | -d | -r | -R ] [ -t <em>timeout</em> ] <em>servicedir</em> <em>prog...</em>
</pre>

<ul>
 <li> s6-svlisten1 checks the state of the <em>servicedir</em>
<a href="servicedir.html">service directory</a> and monitor its
state changes. </li>
 <li> It spawns <em>prog...</em> as a child right after getting the
initial state of the service. </li>
 <li> It then blocks until the wanted state happens. </li>
</ul>

<h2> Exit codes </h2>

<ul>
 <li> 0: success, the wanted state has been reached </li>
 <li> 1: the service was supposed to go up, but reported permanent failure </li>
 <li> 99: timed out </li>
 <li> 100: wrong usage </li>
 <li> 102: the <a href="s6-supervise.html">s6-supervise</a> process monitoring the service died </li>
 <li> 111: system call failed </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-u</tt>&nbsp;: up. s6-svlisten1 will wait until the service is up, as
reported by s6-supervise.
This is the default; it is not reliable, but it does not depend on specific
support in the service programs. See <a href="notifywhenup.html">this page</a>
for details. </li>
 <li> <tt>-U</tt>&nbsp;: really up. s6-svlisten1 will wait until the service is
up <em>and</em> ready as reported by the daemon itself. This requires
specific support in the service programs, and the use of the
<tt>notification-fd</tt> file in the
<a href="servicedir.html">service directory</a>.
See the explanation on <a href="notifywhenup.html">this page</a>. </li>
 <li> <tt>-d</tt>&nbsp;: down. s6-svlisten1 will wait until the service is down. </li>
 <li> <tt>-D</tt>&nbsp;: really down. s6-svlisten1 will wait until the
service is down and the cleanup script in <tt><em>servicedir</em>/finish</tt>
has finished executing (or has timed out and been killed). </li>
 <li> <tt>-r</tt>&nbsp;: restart. s6-svlisten1 will wait until
the service has been started or restarted, i.e. they have been in the
down state, then the up state. </li>
 <li> <tt>-R</tt>&nbsp;: restart and ready. s6-svlisten1 will wait until
the service has been started or restarted and has notified
readiness. </li>
 <li> <tt>-t&nbsp;<em>timeout</em></tt>&nbsp;: if the requested event has not
happened after <em>timeout</em> milliseconds, s6-svlisten1 will print a message
to stderr and exit 99. By default, <em>timeout</em> is 0, which means no time
limit. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> s6-svlisten1 is the service-specific version of
<a href="s6-ftrig-listen1.html">s6-ftrig-listen1</a>. The point of s6-svlisten1
is to use it to spawn a program such as <a href="s6-svc.html">s6-svc</a>,
in order to send signals to a service while making sure to catch its
state changes - thus avoiding the race condition that occurs when running
<a href="s6-svc.html">s6-svc</a> then <a href="s6-svwait.html">s6-svwait</a>
sequentially. </li>
 <li> The <a href="s6-svlisten.html">s6-svlisten</a> program is an extension
of s6-svlisten1. It can watch the state of several services at once; however,
its syntax makes it best used in <a href="//skarnet.org/software/execline/">execline</a>
scripts only. </li>
</ul>

</body>
</html>
